package dto

import (
	"time"

	"go-admin/app/admin/models"
	"go-admin/common/dto"
	common "go-admin/common/models"
)

type AdvertisementsGetPageReq struct {
	dto.Pagination `search:"-"`
	UserId         int64  `form:"userId"  search:"type:exact;column:user_id;table:advertisements" comment:"用户ID"`
	CategoryId     int64  `form:"categoryId"  search:"type:exact;column:category_id;table:advertisements" comment:"类别ID"`
	Title          string `form:"title"  search:"type:contains;column:title;table:advertisements" comment:"标题"`
	Description    string `form:"description"  search:"type:contains;column:description;table:advertisements" comment:"描述"`
	Keyword        string `form:"keyword" search:"-" comment:"关键词"`
	CreateBy       int64  `form:"createBy"  search:"type:exact;column:create_by;table:advertisements" comment:"创建人"`
	Position       string `form:"position"  search:"type:exact;column:position;table:advertisements" comment:"位置"`
	AdvertisementsOrder
}

type AdvertisementsOrder struct {
	Id          string `form:"idOrder"  search:"type:order;column:id;table:advertisements"`
	UserId      string `form:"userIdOrder"  search:"type:order;column:user_id;table:advertisements"`
	CategoryId  string `form:"categoryIdOrder"  search:"type:order;column:category_id;table:advertisements"`
	Title       string `form:"titleOrder"  search:"type:order;column:title;table:advertisements"`
	Description string `form:"descriptionOrder"  search:"type:order;column:description;table:advertisements"`
	Image       string `form:"imageOrder"  search:"type:order;column:image;table:advertisements"`
	Url         string `form:"urlOrder"  search:"type:order;column:url;table:advertisements"`
	Position    string `form:"positionOrder"  search:"type:order;column:position;table:advertisements"`
	StartTime   string `form:"startTimeOrder"  search:"type:order;column:start_time;table:advertisements"`
	EndTime     string `form:"endTimeOrder"  search:"type:order;column:end_time;table:advertisements"`
	Status      string `form:"statusOrder"  search:"type:order;column:status;table:advertisements"`
	Priority    string `form:"priorityOrder"  search:"type:order;column:priority;table:advertisements"`
	Type        string `form:"typeOrder"  search:"type:order;column:type;table:advertisements"`
	Budget      string `form:"budgetOrder"  search:"type:order;column:budget;table:advertisements"`
	Spent       string `form:"spentOrder"  search:"type:order;column:spent;table:advertisements"`
	Impressions string `form:"impressionsOrder"  search:"type:order;column:impressions;table:advertisements"`
	Clicks      string `form:"clicksOrder"  search:"type:order;column:clicks;table:advertisements"`
	CreateBy    string `form:"createByOrder"  search:"type:order;column:create_by;table:advertisements"`
	UpdateBy    string `form:"updateByOrder"  search:"type:order;column:update_by;table:advertisements"`
	CreatedAt   string `form:"createdAtOrder"  search:"type:order;column:created_at;table:advertisements"`
	UpdatedAt   string `form:"updatedAtOrder"  search:"type:order;column:updated_at;table:advertisements"`
	DeletedAt   string `form:"deletedAtOrder"  search:"type:order;column:deleted_at;table:advertisements"`
	Location    string `form:"locationOrder"  search:"type:order;column:location;table:advertisements"`
}

func (m *AdvertisementsGetPageReq) GetNeedSearch() interface{} {
	return *m
}

type AdvertisementsInsertReq struct {
	Id          int       `json:"-" comment:""` //
	UserId      int64     `json:"userId" comment:"用户ID"`
	CategoryId  int64     `json:"categoryId" comment:"类别ID"`
	Title       string    `json:"title" comment:"标题"`
	Description string    `json:"description" comment:"描述"`
	Image       string    `json:"image" comment:"图片"`
	Url         string    `json:"url" comment:"URL"`
	Position    string    `json:"position" comment:"位置"`
	StartTime   time.Time `json:"startTime" comment:"开始时间"`
	EndTime     time.Time `json:"endTime" comment:"结束时间"`
	Status      string    `json:"status" comment:"状态"`
	Priority    int64     `json:"priority" comment:"优先级"`
	Type        string    `json:"type" comment:"类型"`
	Budget      string    `json:"budget" comment:"预算"`
	Spent       string    `json:"spent" comment:"开销"`
	Impressions int64     `json:"impressions" comment:"展示次数"`
	Clicks      int64     `json:"clicks" comment:"点击次数"`
	Location    string    `json:"location" comment:"位置"`
	common.ControlBy
}

func (s *AdvertisementsInsertReq) Generate(model *models.Advertisements) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.UserId = s.UserId
	model.CategoryId = s.CategoryId
	model.Title = s.Title
	model.Description = s.Description
	model.Image = s.Image
	model.Url = s.Url
	model.Position = s.Position
	model.StartTime = s.StartTime
	model.EndTime = s.EndTime
	model.Status = s.Status
	model.Priority = s.Priority
	model.Type = s.Type
	model.Budget = s.Budget
	model.Spent = s.Spent
	model.Impressions = s.Impressions
	model.Clicks = s.Clicks
	model.CreateBy = s.CreateBy // 添加这而，需要记录是被谁创建的
	model.Location = s.Location
}

func (s *AdvertisementsInsertReq) GetId() interface{} {
	return s.Id
}

type AdvertisementsUpdateReq struct {
	Id          int       `uri:"id" comment:""` //
	UserId      int64     `json:"userId" comment:"用户ID"`
	CategoryId  int64     `json:"categoryId" comment:"类别ID"`
	Title       string    `json:"title" comment:"标题"`
	Description string    `json:"description" comment:"描述"`
	Image       string    `json:"image" comment:"图片"`
	Url         string    `json:"url" comment:"URL"`
	Position    string    `json:"position" comment:"位置"`
	StartTime   time.Time `json:"startTime" comment:"开始时间"`
	EndTime     time.Time `json:"endTime" comment:"结束时间"`
	Status      string    `json:"status" comment:"状态"`
	Priority    int64     `json:"priority" comment:"优先级"`
	Type        string    `json:"type" comment:"类型"`
	Budget      string    `json:"budget" comment:"预算"`
	Spent       string    `json:"spent" comment:"开销"`
	Impressions int64     `json:"impressions" comment:"展示次数"`
	Clicks      int64     `json:"clicks" comment:"点击次数"`
	Location    string    `json:"location" comment:"位置"`
	common.ControlBy
}

func (s *AdvertisementsUpdateReq) Generate(model *models.Advertisements) {
	if s.Id == 0 {
		model.Model = common.Model{Id: s.Id}
	}
	model.UserId = s.UserId
	model.CategoryId = s.CategoryId
	model.Title = s.Title
	model.Description = s.Description
	model.Image = s.Image
	model.Url = s.Url
	model.Position = s.Position
	model.StartTime = s.StartTime
	model.EndTime = s.EndTime
	model.Status = s.Status
	model.Priority = s.Priority
	model.Type = s.Type
	model.Budget = s.Budget
	model.Spent = s.Spent
	model.Impressions = s.Impressions
	model.Clicks = s.Clicks
	model.Location = s.Location
	model.UpdateBy = s.UpdateBy // 添加这而，需要记录是被谁更新的
}

func (s *AdvertisementsUpdateReq) GetId() interface{} {
	return s.Id
}

// AdvertisementsGetReq 功能获取请求参数
type AdvertisementsGetReq struct {
	Id int `uri:"id"`
}

func (s *AdvertisementsGetReq) GetId() interface{} {
	return s.Id
}

// AdvertisementsDeleteReq 功能删除请求参数
type AdvertisementsDeleteReq struct {
	Ids []int `json:"ids"`
}

func (s *AdvertisementsDeleteReq) GetId() interface{} {
	return s.Ids
}
